include(PurCCommon)

find_package(Python3 COMPONENTS Development REQUIRED)

set(PY_LIBRARY_TYPE SHARED)

set(PY_PUBLIC_HEADERS
)

set(PY_SOURCES
    python3.c
)

set(PY_PRIVATE_INCLUDE_DIRECTORIES
    "${CMAKE_BINARY_DIR}"
    "${PURC_DIR}"
    "${PURC_DIR}/include"
    "${FORWARDING_HEADERS_DIR}/purc"
    "${PurC_DERIVED_SOURCES_DIR}"
    "${Python3_INCLUDE_DIRS}"
)

set(PY_LIBRARIES
    ${Python3_LIBRARIES}
    ${CMAKE_DL_LIBS}
)

link_directories (${CMAKE_BINARY_DIR}/Source/PurC)
list(APPEND PY_LIBRARIES PurC::PurC Python3::Python)

PURC_FRAMEWORK_DECLARE(PY)
PURC_INCLUDE_CONFIG_FILES_IF_EXISTS()

set_target_properties(PY PROPERTIES OUTPUT_NAME "purc-dvobj-PY")
set_target_properties(PY PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")

PURC_WRAP_SOURCELIST(${PY_SOURCES})
PURC_FRAMEWORK(PY)

install(TARGETS PY DESTINATION "${LIB_INSTALL_DIR}/purc-${PURC_API_VERSION}")

if (MSVC)
    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
    set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
endif ()
